/**********************************************************************
 *File		:	key.h
 *Time		:	2023/6/7
 *Author		:	Bryan He（贺璧）
 *Discreption:
 *
 ************************************************************************/

#ifndef KEY_HHHH____
#define KEY_HHHH____

#include <stdint.h>
#include <stdio.h>
#include <string.h>


/*#TODO: Here need to cfg. that depend on your requirement*/
typedef enum{
    HW_KEY_NULL=0,
    HW_KEY_FRONT_LED,
    HW_MUSIC_DUCKING,
    HW_OUTDOOR_MODE,
    HW_VOICING_MODE,
    HW_FEEDBACK_ELIM,


    HW_KEY_MAX_
}mo_hw_key_t;

#define GPIO_KEY_MAX         HW_KEY_MAX_
#define KEY_POLLING_INTERVAL 5u
#define KEY_DEBOUNCE_TIME    (10 / KEY_POLLING_INTERVAL) /*Ms*/
/**************************************************************/

#define HW_k_NUMBER_ HW_KEY_MAX_

typedef enum{
    IO_K_EVENT_VK_NULL=0,
    IO_K_EVENT_VK_UP,
    IO_K_EVENT_VK_DW,

    IO_K_EVENT_VK_MAX____
}ioKeyEvent;

typedef void (*io_k_event_cb)(ioKeyEvent k_event,mo_hw_key_t kcode);

#ifndef u16
#define u16 uint16_t
#endif

#ifndef u8
#define u8 uint8_t
#endif

typedef struct ex_key_infor {
    mo_hw_key_t kcode;
    void *port; /**/
    u16 pin;
} ExKyeInfo;

typedef struct key_task {
    u8 ex_k_cnt[GPIO_KEY_MAX];
    const ExKyeInfo *pKeyTable;
    //ioKeyEvent k_event;
    u16 app_tick;
    io_k_event_cb k_event_cb;
} KEY_TASK_T;


void io_key_task_handle(void); /*#TODO:Invoked in 1mS loop*/
void io_key_task_init(io_k_event_cb k_event_cb);

#endif